<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<?php 
include("../lib.php");
$link=Conectarse();
$res=mysql_query("SELECT * FROM galerias LIMIT 0 , 8",$link);
$total=mysql_num_rows($res);

$filas=$total/2;
$tipo=$total%2;
if($tipo!=0)
$filas=$filas-1;
$cont=0;
?>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td><h3 align="center"><font face="Verdana, Arial, Helvetica, sans-serif">GALERIA DE IMAGENES</font></h3>
      
<?php 
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";

while($cont < $filas)
{
echo "<tr>";
	
	for($i=0;$i<2;$i++)
	{
	$row= mysql_fetch_array($res);
	  $id=$row["id"];
	  $res2=mysql_query("SELECT * FROM fotos WHERE galeria = '$id' ",$link);
	  $row2= mysql_fetch_array($res2);
	  $foto= $row2["foto"];
	  
printf("<td width='116' background='../album.gif' height='114' valign='middle'>
<div align='center'><a 	href='album.php?id=%s'><img src='imagen.php?ruta=%s&tipo=1' border='0'></a></div></td>
		  <td width='210'><div align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>%s</b></font></div></td>
        
      ",$id,$foto,$row["nombre"]);
	  }
	echo "</tr>";
$cont++;
}
if ($tipo==1)
{
echo "<tr>";	
	$row= mysql_fetch_array($res);
	$id=$row["id"];
	$res2=mysql_query("SELECT * FROM fotos WHERE galeria = '$id' ",$link);
	$row2= mysql_fetch_array($res2);
	$foto= $row2["foto"];
	 printf("<td width='116' background='../album.gif' height='114' valign='middle'>
<div align='center'><a 	href='album.php?id=%s'><img src='imagen.php?ruta=%s&tipo=1' border='0'></a></div></td>
		  <td width='210'><div align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>%s</b></font></div></td>
        
      ",$id,$foto,$row["nombre"]);
	  echo "</tr>";
}
echo "</table>";
	  ?>
	   
	  </td>
  </tr>
</table>
</body>
</html>
